﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.DatabaseServices;

namespace YZQ_DotNetArx.BaseTool
{
    public static class MathTools
    {
        /// <summary>
        /// 判断多段线是否为顺时针
        /// </summary>
        /// <param name="pline">多段线</param>
        /// <returns>是顺时针返回True,不是返回false</returns>
        public static bool IsClockWise(this Polyline pline)
        {
            double area = 0.0;
            for (int i = 0; i < pline.NumberOfVertices - 1; i++)
            {
                Point2d pt1 = pline.GetPoint2dAt(i);
                Point2d pt2 = pline.GetPoint2dAt(i + 1);
                area += pt1.X * pt2.Y - pt2.X * pt1.Y;
            }

            return area < 0;
        }
    }
}
